<template>
 <div style="padding: 16px 20px;position: relative;">
    <div style="width: 400px;height: 100%;display: inline-block;float: right;background-color: white;border-radius: 5px;position: relative;">
      <div v-if="rightPageId==0">
        <div style="padding: 20px 20px;border-bottom: 1px solid var(--color-neutral-4);position: relative;">
            菜单
        </div>
        <div style="padding: 10px 10px;">
          <div class="right-button" @click="rightPageId=1">
              添加院校
              <svg width="15" height="15" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M32.556 24L16.293 7.737a1 1 0 010-1.415l1.414-1.414a1 1 0 011.414 0L36.8 22.586a2 2 0 010 2.828L19.121 43.092a1 1 0 01-1.414 0l-1.414-1.414a1 1 0 010-1.414L32.556 24z" fill="currentColor"/></svg>
          </div>
          <div class="right-button" @click="rightPageId=4">
              导入院校
              <svg width="15" height="15" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M32.556 24L16.293 7.737a1 1 0 010-1.415l1.414-1.414a1 1 0 011.414 0L36.8 22.586a2 2 0 010 2.828L19.121 43.092a1 1 0 01-1.414 0l-1.414-1.414a1 1 0 010-1.414L32.556 24z" fill="currentColor"/></svg>
          </div>
          <div class="right-button" @click="rightPageId=3">
              删除选中的院校
              <svg width="15" height="15" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M32.556 24L16.293 7.737a1 1 0 010-1.415l1.414-1.414a1 1 0 011.414 0L36.8 22.586a2 2 0 010 2.828L19.121 43.092a1 1 0 01-1.414 0l-1.414-1.414a1 1 0 010-1.414L32.556 24z" fill="currentColor"/></svg>
          </div>
          <div class="right-button" @click="rightPageId=5">
              根据专业表更新院校表
              <svg width="15" height="15" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M32.556 24L16.293 7.737a1 1 0 010-1.415l1.414-1.414a1 1 0 011.414 0L36.8 22.586a2 2 0 010 2.828L19.121 43.092a1 1 0 01-1.414 0l-1.414-1.414a1 1 0 010-1.414L32.556 24z" fill="currentColor"/></svg>
          </div>
          <div class="right-button" @click="rightPageId=6">
              在线更新院校表
              <svg width="15" height="15" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M32.556 24L16.293 7.737a1 1 0 010-1.415l1.414-1.414a1 1 0 011.414 0L36.8 22.586a2 2 0 010 2.828L19.121 43.092a1 1 0 01-1.414 0l-1.414-1.414a1 1 0 010-1.414L32.556 24z" fill="currentColor"/></svg>
          </div>
          <!-- <input type="file" ref="upload" accept=".xls,.xlsx" class="outputlist_upload" @change="readExcel1"> -->
        </div>
      </div>
      <div v-if="rightPageId==6" style="position: relative;width: 100%;">
        <div style="padding: 20px 20px;font-size: 14px;border-bottom: 1px solid var(--color-neutral-4);position: relative;padding-left: 55px;">
            <div style="padding: 20px 20px;position: absolute;left: 0;top: 0;cursor: pointer;" @click="()=>{
              if(isOnlineRefreshing)return;
              rightPageId=0
            }">
              <svg width="15" height="15" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.272 24l16.263 16.264a1 1 0 010 1.414l-1.414 1.414a1 1 0 01-1.414 0L11.03 25.414a2 2 0 010-2.828L28.706 4.908a1 1 0 011.414 0l1.415 1.414a1 1 0 010 1.415L15.271 24z" fill="currentColor"/></svg>
            </div>
            在线更新院校表
        </div>
        <div style="padding: 20px 20px;">
          <div style="margin-bottom: 15px;">
            此操作将在线获取所有院校的信息并将其导入到院校表中。
          </div>
          <div style="text-align: right;">
            <a-button type="primary" status="success" style="padding: 0 30px;" :loading="isOnlineRefreshing" @click="onlineRefresh">更新</a-button>
          </div>
        </div>
      </div>
      <div v-if="rightPageId==5" style="position: relative;height: 100%;">
        <div style="padding: 20px 20px;font-size: 14px;border-bottom: 1px solid var(--color-neutral-4);position: relative;padding-left: 55px;">
            <div style="padding: 20px 20px;position: absolute;left: 0;top: 0;cursor: pointer;" @click="()=>{
              if(isRefreshing)return;
              rightPageId=0
            }">
              <svg width="15" height="15" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.272 24l16.263 16.264a1 1 0 010 1.414l-1.414 1.414a1 1 0 01-1.414 0L11.03 25.414a2 2 0 010-2.828L28.706 4.908a1 1 0 011.414 0l1.415 1.414a1 1 0 010 1.415L15.271 24z" fill="currentColor"/></svg>
            </div>
            根据专业表更新院校表
        </div>
        <div style="padding: 20px 20px;">
          <div style="margin-bottom: 15px;">
            此操作将根据专业表中的数据更新每个院校的最低分和最低位次。
          </div>
          <div style="text-align: right;">
            <a-button type="primary" status="success" style="padding: 0 30px;" :loading="isRefreshing" @click="refreshData">更新</a-button>
          </div>
        </div>
      </div>
      <div v-if="rightPageId==1" style="position: relative;height: 100%;">
        <div style="padding: 20px 20px;font-size: 14px;border-bottom: 1px solid var(--color-neutral-4);position: relative;padding-left: 55px;">
            <div style="padding: 20px 20px;position: absolute;left: 0;top: 0;cursor: pointer;" @click="rightPageId=0">
              <svg width="15" height="15" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.272 24l16.263 16.264a1 1 0 010 1.414l-1.414 1.414a1 1 0 01-1.414 0L11.03 25.414a2 2 0 010-2.828L28.706 4.908a1 1 0 011.414 0l1.415 1.414a1 1 0 010 1.415L15.271 24z" fill="currentColor"/></svg>
            </div>
              添加院校
        </div>
        <div style="padding: 20px 20px;height: calc(100% - 112px);overflow-y: scroll;">
          <div style="margin-bottom: 10px;">
            名称
            <a-input v-model="addUniversityForm.name" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入名称"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            标识码
            <a-input v-model="addUniversityForm.remark" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入标识码"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            主管部门
            <a-input v-model="addUniversityForm.department" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入主管部门"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            所在省
            <a-input v-model="addUniversityForm.province" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入所在省"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            所在市
            <a-input v-model="addUniversityForm.city" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入所在市"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            办学层次
            <br>
            <a-radio-group v-model="addUniversityForm.level" style="margin-top: 10px;padding: 10px 5px;border-radius: 3px;width: 100%;border-bottom: 1px solid rgb(0,120,215);">
              <a-radio value="本科">本科</a-radio>
              <a-radio value="专科">专科</a-radio>
            </a-radio-group>
          </div>
          <div style="margin-bottom: 10px;">
            C9/985/211/省重点
            <a-checkbox-group v-model="addUniversityForm.focus" style="margin-top: 10px;padding: 10px 5px;border-radius: 3px;width: 100%;border-bottom: 1px solid rgb(0,120,215);">
              <a-checkbox value="C9">C9</a-checkbox>
              <a-checkbox value="985">985</a-checkbox>
              <a-checkbox value="211">211</a-checkbox>
              <a-checkbox value="省重点">省重点</a-checkbox>
            </a-checkbox-group>
          </div>
          <div style="margin-bottom: 10px;">
            一流大学/一流学科
            <br>
            <a-radio-group v-model="addUniversityForm.firstRate" style="margin-top: 10px;padding: 10px 5px;border-radius: 3px;width: 100%;border-bottom: 1px solid rgb(0,120,215);">
              <a-radio value="无">一流大学</a-radio>
              <a-radio value="一流大学">一流大学</a-radio>
              <a-radio value="一流学科">一流学科</a-radio>
            </a-radio-group>
          </div>
          <div style="margin-bottom: 10px;">
            院校类别
            <a-input v-model="addUniversityForm.type" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入院校类别"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            创办时间
            <a-input v-model="addUniversityForm.year" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入创办时间"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            创办年数
            <a-input v-model="addUniversityForm.yearCount" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入创办年数"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            备注（公办/民办/中外合作办学/...）
            <a-input v-model="addUniversityForm.public" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入备注"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            第一轮双一流建设学科
            <a-input v-model="addUniversityForm.subject1" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入第一轮双一流建设学科"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            第二轮双一流建设高校和建设学科
            <a-input v-model="addUniversityForm.subject2" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入第二轮双一流建设高校和建设学科"></a-input>
          </div>
        </div>
        <div style="text-align: right;padding: 5px 20px;">
          <a-button style="padding: 0 30px;" type="primary" :loading="addUniversityForm.isAdding" @click="addUniversity">添加</a-button>
        </div>
      </div>
      <div v-if="rightPageId==2" style="position: relative;height: 100%;">
        <div style="padding: 20px 20px;font-size: 14px;border-bottom: 1px solid var(--color-neutral-4);position: relative;padding-left: 55px;">
            <div style="padding: 20px 20px;position: absolute;left: 0;top: 0;cursor: pointer;" @click="rightPageId=0">
              <svg width="15" height="15" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.272 24l16.263 16.264a1 1 0 010 1.414l-1.414 1.414a1 1 0 01-1.414 0L11.03 25.414a2 2 0 010-2.828L28.706 4.908a1 1 0 011.414 0l1.415 1.414a1 1 0 010 1.415L15.271 24z" fill="currentColor"/></svg>
            </div>
              修改院校
        </div>
        <div style="padding: 20px 20px;height: calc(100% - 112px);overflow-y: scroll;">
          <div style="margin-bottom: 10px;">
            名称
            <a-input v-model="updateUniversityForm.name" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入名称"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            标识码（不可修改）
            <a-input :disabled="true" v-model="updateUniversityForm.remark" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入标识码"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            主管部门
            <a-input v-model="updateUniversityForm.department" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入主管部门"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            所在省
            <a-input v-model="updateUniversityForm.province" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入所在省"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            所在市
            <a-input v-model="updateUniversityForm.city" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入所在市"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            办学层次
            <br>
            <a-radio-group v-model="updateUniversityForm.level" style="margin-top: 10px;padding: 10px 5px;border-radius: 3px;width: 100%;border-bottom: 1px solid rgb(0,120,215);">
              <a-radio value="本科">本科</a-radio>
              <a-radio value="专科">专科</a-radio>
            </a-radio-group>
          </div>
          <div style="margin-bottom: 10px;">
            C9/985/211/省重点
            <a-checkbox-group v-model="updateUniversityForm.focus" style="margin-top: 10px;padding: 10px 5px;border-radius: 3px;width: 100%;border-bottom: 1px solid rgb(0,120,215);">
              <a-checkbox value="C9">C9</a-checkbox>
              <a-checkbox value="985">985</a-checkbox>
              <a-checkbox value="211">211</a-checkbox>
              <a-checkbox value="省重点">省重点</a-checkbox>
            </a-checkbox-group>
          </div>
          <div style="margin-bottom: 10px;">
            一流大学/一流学科
            <br>
            <a-radio-group v-model="updateUniversityForm.firstRate" style="margin-top: 10px;padding: 10px 5px;border-radius: 3px;width: 100%;border-bottom: 1px solid rgb(0,120,215);">
              <a-radio value="">无</a-radio>
              <a-radio value="一流大学">一流大学</a-radio>
              <a-radio value="一流学科">一流学科</a-radio>
            </a-radio-group>
          </div>
          <div style="margin-bottom: 10px;">
            院校类别
            <a-input v-model="updateUniversityForm.type" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入院校类别"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            创办时间
            <a-input v-model="updateUniversityForm.year" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入创办时间"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            创办年数
            <a-input v-model="updateUniversityForm.yearCount" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入创办年数"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            备注（公办/民办/中外合作办学/...）
            <a-input v-model="updateUniversityForm.public" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入备注"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            第一轮双一流建设学科
            <a-input v-model="updateUniversityForm.subject1" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入第一轮双一流建设学科"></a-input>
          </div>
          <div style="margin-bottom: 10px;">
            第二轮双一流建设高校和建设学科
            <a-input v-model="updateUniversityForm.subject2" allow-clear style="height: 35px;background-color: white;border: 0px;border-bottom: 1px solid rgb(0,120,215);padding: 0 0;margin-top: 5px;" placeholder="请输入第二轮双一流建设高校和建设学科"></a-input>
          </div>
        </div>
        <div style="text-align: right;padding: 5px 20px;">
          <a-button style="padding: 0 30px;" type="primary" :loading="updateUniversityForm.isAdding" @click="updateUniversity">保存</a-button>
        </div>
      </div>
      <div v-if="rightPageId==3" style="position: relative;height: 100%;">
        <div style="padding: 20px 20px;font-size: 14px;border-bottom: 1px solid var(--color-neutral-4);position: relative;padding-left: 55px;">
            <div style="padding: 20px 20px;position: absolute;left: 0;top: 0;cursor: pointer;" @click="rightPageId=0">
              <svg width="15" height="15" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.272 24l16.263 16.264a1 1 0 010 1.414l-1.414 1.414a1 1 0 01-1.414 0L11.03 25.414a2 2 0 010-2.828L28.706 4.908a1 1 0 011.414 0l1.415 1.414a1 1 0 010 1.415L15.271 24z" fill="currentColor"/></svg>
            </div>
              删除选中的院校
        </div>
        <div style="padding: 20px 20px;">
          <div style="margin-bottom: 15px;">
            此操作将删除选中的院校且不可恢复。
          </div>
          <div style="text-align: right;">
            <a-button type="primary" status="danger" style="padding: 0 30px;" :loading="isDeleting" @click="deleteSelected">删除</a-button>
          </div>
        </div>
      </div>
      <div v-if="rightPageId==4" style="position: relative;height: 100%;">
        <div style="padding: 20px 20px;font-size: 14px;border-bottom: 1px solid var(--color-neutral-4);position: relative;padding-left: 55px;">
            <div style="padding: 20px 20px;position: absolute;left: 0;top: 0;cursor: pointer;" @click="rightPageId=0">
              <svg width="15" height="15" viewBox="0 0 48 48" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.272 24l16.263 16.264a1 1 0 010 1.414l-1.414 1.414a1 1 0 01-1.414 0L11.03 25.414a2 2 0 010-2.828L28.706 4.908a1 1 0 011.414 0l1.415 1.414a1 1 0 010 1.415L15.271 24z" fill="currentColor"/></svg>
            </div>
              导入院校
        </div>
        <div style="padding: 20px 20px;">
          <div style="line-height: 25px;margin-bottom: 20px;">
                <p>表格文件要求</p>
                <p>1.专业数据应保存在表格文件的第一个表格中；</p>
                <p>2.表格的第一行应为每一列数据的标题，并且必须包括“名称”、“标识码”、“主管部门”、“所在省”、“所在市”、“办学层次”、“C9/985/211/省重点”、“一流大学/一流学科”、“院校类别”、“创办时间”、“创办年数”、“备注”、“第一轮双一流建设学科”、“第二轮双一流建设高校及建设学科”这几个标题；</p>
                <p>3.如果表格文件符合上面的要求但是不能正常导入，可能是表格内某些单元格的值过长造成的。</p>
              </div>
              <a-steps label-placement="horizontal" direction="vertical" :current="importMajorStep">
                <a-step>选择Excel文件
                  <br>
                  <input style="font-size: 14px;" :disabled="importUniversityStep!=1" type="file" ref="upload" accept=".xls,.xlsx" class="outputlist_upload" @change="readExcel">
                  <br>
                  <div v-if="imporUniversityWarningText!=''" style="line-height: 30px;color: red;margin-bottom: 15px;">
                    {{ importUniversityWarningText }}
                  </div>
                </a-step>
                <a-step>正在导入
                  <br>
                  <a-button v-if="importUniversityStep==2" :loading="true" style="background-color: white !important;color: black !important;margin-top: 10px;">正在处理，请耐心等待。
                    <br>请不要关闭浏览器或离开当前页面。
                    <br>已完成{{  parseInt(importedUniversitiesNum/importUniversitiesNum*100) }}%
                  </a-button>
                </a-step>
                <a-step>完成导入
                  <br>
                  <div v-if="importUniversityStep==3" style="font-size: 14px;">
                    共导入{{ importUniversitiesNum }}个院校。
                  </div>
                </a-step>
              </a-steps>

        </div>
      </div>
    </div>
    <div style="width: calc(100% - 420px);height: 100%;display: inline-block;float: left;border-radius: 5px;background-color: white;">
      <div style="padding: 20px 20px;border-bottom: 1px solid var(--color-neutral-4);position: relative;">
          院校管理
      </div>
      <div style="padding: 20px 20px;">
        <div>
          <span>
            <div style="display: inline-block;width: calc(25% - 4px);">
              学校名称
              <a-input v-model="searchForm.name" allow-clear style="border: 0px;border-bottom: 1px solid rgb(0,120,215);background-color: white;padding: 0 0;height: 35px;" placeholder="请输入学校名称"></a-input>
            </div>
          </span>
          <span style="margin-left: 5.3px;">
            <div style="display: inline-block;width: calc(25% - 4px);">
              学校标识码
              <a-input v-model="searchForm.remark" allow-clear style="border: 0px;border-bottom: 1px solid rgb(0,120,215);background-color: white;padding: 0 0;height: 35px;" placeholder="请输入学校标识码"></a-input>
            </div>
          </span>
          <span style="margin-left: 5.3px;">
            <div style="display: inline-block;width: calc(25% - 4px);">
              所在省
              <a-input v-model="searchForm.province" allow-clear style="border: 0px;border-bottom: 1px solid rgb(0,120,215);background-color: white;padding: 0 0;height: 35px;" placeholder="请输入所在省"></a-input>
            </div>
          </span>
          <span style="margin-left: 5.3px;">
            <div style="display: inline-block;width: calc(25% - 4px);">
              所在市
              <a-input v-model="searchForm.city" allow-clear style="border: 0px;border-bottom: 1px solid rgb(0,120,215);background-color: white;padding: 0 0;height: 35px;" placeholder="请输入所在市"></a-input>
            </div>
          </span>
        <div style="text-align: right;margin-top: 10px;margin-bottom: 10px;">
          <a-button :loading="searchForm.isSearching" style="padding: 0 30px;" @click="()=>{
            searchForm.name='';
            searchForm.remark='';
            searchForm.province='';
            searchForm.city='';
            getUniversities();
          }">显示全部</a-button>
          <a-button style="padding: 0 30px;margin-left: 10px;" type="primary" :loading="searchForm.isSearching" @click="getUniversities">查找</a-button>
        </div>
        </div>
        <div>
          <a-table v-model:selected-keys="selectedKeys" :row-selection="{
      type: 'checkbox',
      showCheckedAll: true
    }" @row-click="openUniversity" :loading="searchForm.isSearching" :data="universities" style="height: ;" :columns="[
            {
              title: '名称',
              dataIndex: 'name',
            },
            {
              title: '标识码',
              dataIndex: 'remark',
            },
            {
              title: '所在省',
              dataIndex: 'province',
            },
            {
              title: '所在市',
              dataIndex: 'city',
            },
    ]"></a-table>
        </div>
      </div>
      
    </div>
 </div>
</template>

<script>
import { read, utils } from 'xlsx'
import * as XLSX from 'xlsx'
// const xlsx = XLSX
import axios from 'axios'
// import path from 'path'

export default{
  data(){
    return{
      searchForm:{
        name:'',
        remark:'',
        province:'',
        city:'',
        isSearching:false,
      },
      universities:[],
      rightPageId:0,
      addUniversityForm:{
        name:'',
        remark:'',
        department:'',
        province:'',
        city:'',
        level:'本科',
        focus:[],
        firstRate:'一流大学',
        type:'',
        year:'',
        yearCount:'',
        public:'',
        subject1:'',
        subject2:'',
        isAdding:false,
      },
      addUniversityFormModel:{
          name:'',
          remark:'',
          department:'',
          province:'',
          city:'',
          level:'本科',
          focus:[],
          firstRate:'一流大学',
          type:'',
          year:'',
          yearCount:'',
          public:'',
          subject1:'',
          subject2:'',
        isAdding:false,
      },
      updateUniversityForm:undefined,
      isUpdating:false,
      selectedKeys:[],
      isDeleting:false,
      importUniversityStep:1,
      importUniversityWarningText:'',
      importedUniversitiesNum:0,
      importUniversitiesNum:0,
      isRefreshing:false,
      isOnlineRefreshing:false,
    }
  },
  mounted(){
    this.getUniversities();
  },
  methods:{
    onlineRefresh(){
      this.isOnlineRefreshing=true;
      var config = {
   method: 'post',
   url: '/api/v1/universities/onlineRefresh',
   headers: { 
      'Accept': '*/*'
   }
};

axios(config)
.then((res)=> {
  this.isOnlineRefreshing=false;
  if(res.data.status==1){
    this.getUniversities();
  }else{
    // 
  }
})
    },
    refreshData(){
      this.isRefreshing=true;
      var config = {
   method: 'post',
   url: '/api/v1/universities/refresh',
   headers: { 
      'Accept': '*/*', 
   }
};

axios(config)
.then((res) => {
  this.isRefreshing=false;
   if(res.data.status==1){
    this.rightPageId=0;
   }else{
    this.$message.error({
      content:res.data.content
    })
   }
})
    },
    deleteSelected(){
      if(this.selectedKeys.length==0){
        this.$message.error({
          content:'未选择院校'
        })
        return;
      }
      this.isDeleting=true;
      var config = {
   method: 'post',
   url: '/api/v1/universities/deleteSelected?data=' + JSON.stringify(this.selectedKeys),
   headers: { 
      'Accept': '*/*', 
   }
};

axios(config)
.then(()=> {
  this.isDeleting=false;
  this.rightPageId=0;
  this.getUniversities();
})
    },
    readExcel(e) {
      this.importMajorWarningText='';
//  var that = this;
const files = e.target.files;
// 如果没有文件名
if(files.length<=0){
return false;
}else if(!/\.(xls|xlsx)$/.test(files[0].name.toLowerCase())){
this.$Message.error('上传格式不正确，请上传xls或者xlsx格式');
return false;
}
this.importUniversityStep=2;
const fileReader = new FileReader();
fileReader.onload = (ev) => {
try {
const data = ev.target.result;
// 切换为新的调用方式
const workbook = read(data, {
type: 'binary'
});
// 取第一张表
const wsname = workbook.SheetNames[0];
// 切换为新的调用方式 生成json表格内容
const ws = utils.sheet_to_json(workbook.Sheets[wsname]);
console.log(ws);
// 后续为自己对ws数据的处理
this.importUniversitiesNum=ws.length;
this.importedUniversitiesNum=0;
this.importUniversities(ws,0);

} catch (e) {
return false;
}
};
fileReader.readAsBinaryString(files[0]);
},
    readExcel1(e) {
      this.importMajorWarningText='';
//  var that = this;
const files = e.target.files;
// 如果没有文件名
if(files.length<=0){
return false;
}else if(!/\.(xls|xlsx)$/.test(files[0].name.toLowerCase())){
this.$Message.error('上传格式不正确，请上传xls或者xlsx格式');
return false;
}
const fileReader = new FileReader();
fileReader.onload = (ev) => {
try {
const data = ev.target.result;
// 切换为新的调用方式
const workbook = read(data, {
type: 'binary'
});
// 取第一张表
const wsname = workbook.SheetNames[0];
// 切换为新的调用方式 生成json表格内容
const ws = utils.sheet_to_json(workbook.Sheets[wsname]);
console.log(ws);
// 后续为自己对ws数据的处理
let re = [];
for(let i=0;i<ws.length;i++){
  if(ws[i]['__EMPTY_5']==undefined){
    continue;
  }
  re.push([ws[i]['2022年夏季高考文化成绩一分一段表'],ws[i]['__EMPTY'],ws[i]['__EMPTY_1'],ws[i]['__EMPTY_2'],ws[i]['__EMPTY_3'],ws[i]['__EMPTY_4'],ws[i]['__EMPTY_5'],ws[i]['__EMPTY_6'],ws[i]['__EMPTY_7'],ws[i]['__EMPTY_8'],ws[i]['__EMPTY_9'],ws[i]['__EMPTY_10']]);
}
console.log(re)
var ws_name = "sheet1";
const ws_data = re;
var ws1 = XLSX.utils.aoa_to_sheet(ws_data);
var wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws1, ws_name);
XLSX.writeFile(wb, "导出.xlsx");

} catch (e) {
return false;
}
};
fileReader.readAsBinaryString(files[0]);
},
    importUniversities(re,start,resend){
      let pre = [];
      for(let i=start;i<start+10;i++){
        if(re[i]==undefined){
          continue;
        }
        pre.push(re[i]);
      }
      if(resend!=undefined){
        pre=resend;
      }
      var config = {
   method: 'post',
   url: '/api/v1/universities/import',
   headers: { 
      'Accept': '*/*', 
   },
   data : pre
};

axios(config)
.then((res) => {
  if(res.data.status==2){
    this.importUniversities(re,start,pre);
  }else{
    this.importedUniversitiesNum+=pre.length;
   if(start+10<=re.length-1){
    this.importUniversities(re,start+10);
   }else{
    this.importUniversityStep=3;
    this.getUniversities();
   }
  }
    
})
    },
    openUniversity(e){
      this.updateUniversityForm=e;
      this.updateUniversityForm.focus=this.convertStringToArray(JSON.parse(JSON.stringify(e.focus)).toString());
      this.rightPageId=2;
    },
    convertStringToArray(str) {
  // 使用逗号作为分隔符将字符串分割为数组
  var arr = str.split(',');

  // 使用map方法对数组中的每个元素进行处理，去除首尾的空格
  arr = arr.map(function(item) {
    return item.trim();
  });

  return arr;
},
    updateUniversity(){
if(this.updateUniversityForm.name==''){
  this.$message.error({
    content:'未输入名称'
  });
  return;
}
if(this.updateUniversityForm.department==''){
  this.$message.error({
    content:'未输入主管部门'
  });
  return;
}
if(this.updateUniversityForm.province==''){
  this.$message.error({
    content:'未输入所在省'
  });
  return;
}
if(this.updateUniversityForm.city==''){
  this.$message.error({
    content:'未输入所在市'
  });
  return;
}
if(this.updateUniversityForm.type==''){
  this.$message.error({
    content:'未输入院校类型'
  });
  return;
}
if(this.updateUniversityForm.year==''){
  this.$message.error({
    content:'未输入创办时间'
  });
  return;
}
if(this.updateUniversityForm.yearCount==''){
  this.$message.error({
    content:'未输入创办年数'
  });
  return;
}
if(this.updateUniversityForm.public==''){
  this.$message.error({
    content:'未输入备注'
  });
  return;
}
      this.isUpdating=true;
      var config = {
        method: 'post',
        url:
         '/api/v1/universities/update?data=' + JSON.stringify(this.updateUniversityForm),
        headers: { 
          'Accept': '*/*', 
        }
      };

      axios(config)
      .then((res) => {
        this.isUpdating=false;
         if(res.data.status==1){
          this.rightPageId=0;
          this.getUniversities();
         }else{
          this.$message.error({
            content:"修改失败"
          })
         }
      })
    },
    addUniversity(){
      if(this.addUniversityForm.name==''){
        this.$message.error({
          content:'未输入名称'
        });
        return;
      }
      if(this.addUniversityForm.remark==''){
        this.$message.error({
          content:'未输入标识码'
        });
        return;
      }
      if(this.addUniversityForm.department==''){
        this.$message.error({
          content:'未输入主管部门'
        });
        return;
      }
      if(this.addUniversityForm.province==''){
        this.$message.error({
          content:'未输入所在省'
        });
        return;
      }
      if(this.addUniversityForm.city==''){
        this.$message.error({
          content:'未输入所在市'
        });
        return;
      }
      if(this.addUniversityForm.type==''){
        this.$message.error({
          content:'未输入院校类型'
        });
        return;
      }
      if(this.addUniversityForm.year==''){
        this.$message.error({
          content:'未输入创办时间'
        });
        return;
      }
      if(this.addUniversityForm.yearCount==''){
        this.$message.error({
          content:'未输入创办年数'
        });
        return;
      }
      if(this.addUniversityForm.public==''){
        this.$message.error({
          content:'未输入备注'
        });
        return;
      }
      this.addUniversityForm.isAdding=true;
      var config = {
   method: 'post',
   url: '/api/v1/universities/add?data=' +  JSON.stringify(this.addUniversityForm),
   headers: { 
      'Accept': '*/*', 
   }
};

axios(config)
.then((res) => {
  this.addUniversityForm.isAdding=false;
   if(res.data.status==1){
      this.addUniversityForm=this.addUniversityFormModel;
      this.getUniversities();
   }else{
      this.$message.error({
        content:'添加失败'
      })
   }
})
    },
    getUniversities(){
      this.searchForm.isSearching=true;
      var config = {
        method: 'get',
        url: '/api/v1/universities/search?data=' + JSON.stringify({
          name:this.searchForm.name,
          remark:this.searchForm.remark,
          province:this.searchForm.province,
          city:this.searchForm.city,
        }),
        headers: { 
            'Accept': '*/*', 
        }
      };

      axios(config)
      .then((res) => {
        this.searchForm.isSearching=false;
        if(res.data.status==1){
          let pre = res.data.results;
          for(let i=0;i<pre.length;i++){
            pre[i]['key']=pre[i].remark;
          }
          this.universities=pre;
        }else{
          this.$message.error({
            content:res.data.content
          })
        }
      })
    }
  },
  props:{

  },
}
</script>

<style scoped>

.right-button svg{
  position: absolute;
  right: 15px;
  top: 15px;
}

.right-button:hover{
  background-color: rgb(242,242,242);
}

.right-button{
  width: 100%;
  padding: 15px 15px;
  border-radius: 5px;
  cursor: pointer;
  line-height: 15px;
  position: relative;
  margin-bottom: 5px;
}

</style>